package vista;



/* Laboratorio 1 (Lunes 1:00 p.m.)
 * 
 * Integrantes:
 * 
 * Mariela Carrera   CI. 18683533
 * 
 * Abraham Mogollón  CI. 18136645
 * 
 * Lianeth Barazarte CI. 20188630
 * 
 * Johann Morales    CI 17627581
 * 
 * */


import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import java.awt.FlowLayout;
import java.awt.Dimension;
import java.awt.BorderLayout;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import controlador.ControladorPrincipal;
import java.awt.event.KeyEvent;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaPrincipal extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JLabel logoSistema = null;
	private JPanel panelNorte = null;
	private JMenuBar menuPrincipal = null;
	private JMenu menuModulos = null;
	
	private JMenuItem itemProductos = null;

	private JMenuItem itemClientes = null;
	
	private JMenuItem itemCompra = null;
	
	private JMenuItem itemSalir = null;
	private JMenuItem itemIngredientes = null;
	private JMenuItem itemOrden = null;
	private JMenu jMenuOper;
	private JMenuItem itemGenerales;
	private JMenu jMenu1;

	private JMenuItem itemCategoria = null;
	
	

	private JPanel getPanelNorte() {
		if (panelNorte == null) {
			FlowLayout flowLayout = new FlowLayout();
			flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
			flowLayout.setVgap(5);
			flowLayout.setHgap(5);
			panelNorte = new JPanel();
			panelNorte.setLayout(flowLayout);
			panelNorte.setBackground(new java.awt.Color(0,0,0));
			panelNorte.add(logoSistema, null);
		}
		return panelNorte;
	}

	
	public JMenuBar getMenuPrincipal() {
		if (menuPrincipal == null) {
			menuPrincipal = new JMenuBar();
			menuPrincipal.setBackground(new java.awt.Color(100,177,255));
			menuPrincipal.setForeground(new java.awt.Color(0,0,0));
			menuPrincipal.add(getMenuModulos());
			menuPrincipal.add(getJMenuOper());
			menuPrincipal.add(getJMenu1());

		}
		return menuPrincipal;
	}

	
	public JMenu getMenuModulos() {
		if (menuModulos == null) {
			menuModulos = new JMenu();
			menuModulos.setText("Tablas");
			
			menuModulos.setEnabled(true);
			menuModulos.setBackground(new java.awt.Color(255,255,255));

			menuModulos.add(getItemCategoria());
			menuModulos.add(getItemIngredientes());
			menuModulos.add(getItemProductos());

			menuModulos.add(getItemClientes());

			
			
		}
		return menuModulos;
	}

	
	
	
	public JMenuItem getItemCompra() {
		if (itemCompra == null) {
			itemCompra = new JMenuItem();
			itemCompra.setText("Compra");
			//itemProductos.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Libros.png")));
			itemCompra.setBackground(new java.awt.Color(100,177,255));
			itemCompra.setMnemonic(KeyEvent.VK_UNDEFINED);
		}
		return itemCompra;
	}


	public void setItemCompra(JMenuItem itemCompra) {
		this.itemCompra = itemCompra;
	}


	public JMenuItem getItemProductos() {
		if (itemProductos == null) {
			itemProductos = new JMenuItem();
			itemProductos.setText("Productos");
			//itemProductos.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Libros.png")));
			itemProductos.setMnemonic(KeyEvent.VK_UNDEFINED);
			//itemProductos.setBackground(new java.awt.Color(79,167,255));
			itemProductos.setBackground(new java.awt.Color(100,177,255));
			
		}
		return itemProductos;
	}

	
	public JMenuItem getItemClientes() {
		if (itemClientes == null) {
			itemClientes = new JMenuItem();
			itemClientes.setText("Clientes");
			//itemClientes.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Empleados.png")));
			itemClientes.setMnemonic(KeyEvent.VK_UNDEFINED);
			itemClientes.setBackground(new java.awt.Color(100,177,255));
		}
		return itemClientes;
	}

	
	public JMenuItem getItemCliente() {
		if (itemClientes == null) {
			itemClientes = new JMenuItem();
			itemClientes.setText("Clientes");
			//itemClientes.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Usuarios.png")));
			itemClientes.setMnemonic(KeyEvent.VK_UNDEFINED);
			itemClientes.setBackground(new java.awt.Color(100,177,255));
		}
		return itemClientes;
	}

	
	
	public void registrarControlador(){
		
		ControladorPrincipal controladorPrincipal = new ControladorPrincipal(this);
		
		itemCategoria.addActionListener(controladorPrincipal);
		itemProductos.addActionListener(controladorPrincipal);		
		itemOrden.addActionListener(controladorPrincipal);
		
		
		itemClientes.addActionListener(controladorPrincipal);		
		itemIngredientes.addActionListener(controladorPrincipal);
		itemCompra.addActionListener(controladorPrincipal);
		
		itemGenerales.addActionListener(controladorPrincipal);
		
		addWindowListener(controladorPrincipal);
	}
	
	
	public JMenuItem getItemSalir() {
		
		if (itemSalir == null) {
			itemSalir = new JMenuItem();
			itemSalir.setText("Salir");
			//itemSalir.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Cancelar.png")));
		}
		return itemSalir;
	}

	
	public JMenuItem getItemIngredientes() {
		if (itemIngredientes == null) {
			itemIngredientes = new JMenuItem();
			itemIngredientes.setText("Ingredientes");
			//itemIngredientes.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Ejemplar.png")));
			itemIngredientes.setBackground(new java.awt.Color(100,177,255));
		}
		return itemIngredientes;
	}

	
	public JMenuItem getItemOrden() {
		if (itemOrden == null) {
			itemOrden = new JMenuItem();
			itemOrden.setText("Orden");
			itemOrden.setBounds(-39, 65, 88, 21);
			//itemOrden.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Ejemplar.png")));
			itemOrden.setBackground(new java.awt.Color(100,177,255));
		}
		return itemOrden;
	}

	
	
	
	public JMenuItem getItemCategoria() {
		if (itemCategoria == null) {
		
			itemCategoria = new JMenuItem();
			itemCategoria.setText("Categoria");			
			//itemCategoria.setIcon(new ImageIcon(getClass().getResource("/imagenes/btn_Modificar.png")));
			itemCategoria.setBackground(new java.awt.Color(100,177,255));
		}
		return itemCategoria;
	}

	
		
	public VistaPrincipal() {
		super();
	
		initialize();
		registrarControlador();		
	}

	private void initialize() {
		this.setSize(605, 420);
		this.setLocation(new java.awt.Point(0,0));
		this.setResizable(false);
		this.setMaximumSize(new Dimension(1024, 768));
		this.setMinimumSize(new Dimension(640, 480));
		this.setJMenuBar(getMenuPrincipal());
		this.setContentPane(getJContentPane());
		this.setTitle("Sistema <<La Guapa>>   Comida Rapida");
		this.setVisible(true);
		this.setLocationRelativeTo(null);
		this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("imagenes/btn_Reportes.png")).getImage());
		//System.out.println(getNombreUsuario());
	
	}
	
	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			logoSistema = new JLabel();
			//logoSistema.setIcon(new ImageIcon(getClass().getResource("/imagenes/BibliosSystem.png")));
			logoSistema.setText("");
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.setBackground(new java.awt.Color(255,255,255));
			jContentPane.setPreferredSize(new java.awt.Dimension(634, 253));
			jContentPane.add(getPanelNorte(), BorderLayout.NORTH);
		}
		return jContentPane;
	}
	
	
	/*public static void main(String[] args) {
		
		new VistaPrincipal();
	}*/
	
	public JMenu getJMenu1() {
		if(jMenu1 == null) {
			jMenu1 = new JMenu();
			jMenu1.setText("Reportes");
			jMenu1.add(getItemGenerales());
		}
		return jMenu1;
	}
	
	public JMenuItem getItemGenerales() {
		if(itemGenerales == null) {
			itemGenerales = new JMenuItem();
			itemGenerales.setText("Generales");
			itemGenerales.setBackground(new java.awt.Color(100,177,255));
		}
		return itemGenerales;
	}
	
	public JMenu getJMenuOper() {
		if(jMenuOper == null) {
			jMenuOper = new JMenu();
			jMenuOper.setText("Operaciones");
			jMenuOper.setBounds(39, 21, 83, 25);
			jMenuOper.add(getItemOrden());
			
			//menuModulos.add(getItemCompra());
			jMenuOper.add(getItemCompra());
			
		}
		return jMenuOper;
	}
	
	
	
	

}  //  @jve:decl-index=0:visual-constraint="10,10"
